home *** CD-ROM | disk | FTP | other *** search
/ Micromanía 85 / CDMM85_1.ISO / Monopoly Tycoon / MTycoonDemo.exe / data1.cab / scripts / DEFAULT / auctioncamera.lua < prev    next >
Encoding:
Text File  |  2001-10-24  |  3.7 KB  |  132 lines

  1. -------------------------------------------------------
  2. ------- Initialise any globals for these functions ----
  3. -------------------------------------------------------
  4.  
  5.  
  6. -------------------------------------------------------
  7. ------- AuctionIntroCam function ----------------------
  8. -------------------------------------------------------
  9. function EVENTINITIALISE_AuctionIntroCamera()
  10.     -- the auction camera consists of three cameras one after another
  11.     intro_camnum = 1;    -- was 3 -- KAT 19/01/01 keeps a record of which camera to be running
  12.     first_time = 1;        -- tells the sub cameras that this is the first time they are being run, 
  13.                         -- so they can initialise
  14.     bezu = 0;            -- used to control bezier progression
  15.     maxspeed = 0.1;        -- sets the maxspeed of the camera movement along the bezier path
  16.     speed = 0.01;        -- current speed along bezier path
  17.     acceleration = 0;    -- change in speed
  18.     Camera.SetMode(FREECAM); -- set the camera mode to one we can control
  19.     Camera.posinertia = FALSE;    -- set up initial camera variables
  20.     Camera.targinertia = FALSE;
  21.     Camera.inertiavalue = 1;
  22. end;
  23.  
  24. function EVENT_AuctionIntroCamera()
  25.     if intro_camnum == 3 then
  26.         if LUA_AuctionIntro1() == 0 then 
  27.             intro_camnum = intro_camnum - 1 
  28.         end;
  29.     end;
  30.     if intro_camnum == 2 then
  31.         if LUA_AuctionIntro2() == 0 then 
  32.             intro_camnum = intro_camnum - 1 
  33.         end;
  34.     end;
  35.  
  36.     if intro_camnum == 1 then
  37.         return LUA_AuctionIntroFinal();
  38.     end;
  39.     return 1;
  40. end;
  41.  
  42. function LUA_AuctionIntro1()
  43.  
  44.     if firsttime == 1 then
  45.         firsttime = 0;    -- switch it off
  46.         maxspeed = 0.005;
  47.         speed = 0.0000000000000001;
  48.         acceleration = 0.0001;
  49.  
  50.         Camera.SetPositionPath    -- call c function to create position path
  51.         (0.6,    4.8,    33,
  52.         11,    10.4,    12.3,
  53.         11,    10.4,    12.3,
  54.         11,    10.4,    12.3);
  55.  
  56.         Camera.SetLookatPath    -- call c function to create lookat path
  57.         (-15,    0.8,    131.8,
  58.         -25.9,    7.4,    105.2,
  59.         -25.9,    7.4,    105.2,
  60.         -25.9,    7.4,    105.2);
  61.     end;
  62.  
  63.     Camera.BezCalcPosition(bezu);    -- call c function to update camera position based on bezier path
  64.     Camera.BezCalcLookat(bezu);    -- call c function to update camera lookat based on bezier path
  65.     bezu = bezu + speed;            -- update bezu ( position along bezier curve from 0 to 1 )
  66.     speed = speed + acceleration;    -- update speed
  67.     if speed > maxspeed then        -- make sure we haven't gone over maxspeed
  68.         speed = maxspeed;            -- if we have, then clamp
  69.     end;
  70.  
  71.     if bezu > 1 then                -- test to see if we have reached the end of the curve
  72.         firsttime = 1;                -- rest first time, for the next camera
  73.         return 0;                    -- return 0 to the calling function to let it know this camera is done
  74.     else
  75.         return 1;                    -- return 1 to the calling 
  76.     end;
  77. end;
  78.  
  79. function LUA_AuctionIntro2()
  80.  
  81.     if firsttime == 1 then
  82.         firsttime = 0;
  83.         bezu = 0;
  84.         speed = 0.003;
  85.         acceleration = 0;
  86.  
  87.         Camera.SetPositionPath
  88.         (-5,    4.7,    39.5,
  89.          -2,    4.7,    40,
  90.         5.8,    4.7,    37.5,
  91.         8.2,    3.7,    31.1);
  92.  
  93.         Camera.SetLookatPath
  94.         (7.7,    -17.2,    -62.2,
  95.         -5.1,    -12.2,    -62.8,
  96.         -33.1,    -16.2,    -57.5,
  97.         -61.7,    -14.2,    -44.1);
  98.     end;
  99.     
  100.     Camera.BezCalcPosition(bezu);
  101.     Camera.BezCalcLookat(bezu);
  102.     bezu = bezu + speed;
  103.     speed = speed + acceleration;
  104.     if speed > maxspeed then
  105.         speed = maxspeed;
  106.     end;
  107.  
  108.     if bezu > 1 then
  109.         firsttime = 1;
  110.         return 0;    
  111.     else
  112.         return 1;
  113.     end;
  114. end;
  115.  
  116. function LUA_AuctionIntroFinal()
  117.     Camera.x,    Camera.y,    Camera.z = Camera.GetActorPosition(0);
  118.     Camera.x =    Camera.x - 1;
  119.     Camera.y =    Camera.y + 5;
  120.     Camera.z =    Camera.z + 5;
  121.     Camera.lx,    Camera.ly,    Camera.lz = Camera.GetActorPosition(0);
  122.     Camera.lx = Camera.lx - 0.5;
  123.     Camera.ly = 2;
  124.     Camera.lz = Camera.lz - 12;
  125.     return 0;
  126. end;
  127.  
  128.  
  129. -------------------------------------------------------
  130. -------------------------------------------------------
  131. -------------------------------------------------------
  132.